package com.et.mserver;

import java.nio.ByteBuffer;

public class BinaryMessageSegment {

	public BinaryMessageSegment(final byte[] byteArray, final boolean lastSegment) {

		this.buffer = ByteBuffer.wrap(byteArray);
		this.lastSegment = lastSegment;
	}

	public byte[] getBuffer() {

		if (buffer == null) {
			return null;
		}

		this.buffer.rewind();

		final ByteBuffer bb = this.buffer;
		final byte[] bytes = new byte[bb.remaining()];
		bb.get(bytes);

		return bytes;
	}

	public boolean isLastSegment() {

		return lastSegment;
	}

	private boolean lastSegment = false;
	private ByteBuffer buffer = null;
}
